﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="userList.aspx.cs" Inherits="WingtipToys.Account.userList" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <div style="width:600px;margin-left:auto;margin-right:auto;padding-top:50px;padding-bottom:50px">
    <asp:GridView
        ID="GridView1"
        runat="server"
        AutoGenerateColumns="False"
        DataKeyNames="UserName"
        AutoGenerateEditButton="True"
        DataSourceID="SqlDataSource1"
        BorderWidth="1px" BackColor="#DEBA84"
        CellPadding="3" CellSpacing="2" BorderStyle="None"
        BorderColor="#DEBA84"

        >
        <FooterStyle ForeColor="#8C4510"
            BackColor="#F7DFB5"></FooterStyle>
        <PagerStyle ForeColor="#8C4510"
            HorizontalAlign="Center"></PagerStyle>
        <HeaderStyle ForeColor="White" Font-Bold="True"
            BackColor="blue" HorizontalAlign="Center"></HeaderStyle>
        
        <Columns>
            <asp:TemplateField HeaderText="User ID" ItemStyle-Width="20px">
                <ItemTemplate>
                    <%# Eval("UserId") %>
                </ItemTemplate>

                <EditItemTemplate>
                    <asp:TextBox ID="txtUserId" runat="Server" Text='<%# Eval("UserId") %>'  ></asp:TextBox>
                    <asp:RequiredFieldValidator ID="req3" runat="Server" Text="*" ControlToValidate="txtUserId"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            
            <asp:TemplateField HeaderText="User Name" ItemStyle-Width="100px">
                <ItemTemplate>
                    <%# Eval("UserName") %>
                </ItemTemplate>

                <EditItemTemplate>
                    <asp:TextBox ID="txtUserName" runat="Server" Text='<%# Eval("UserName") %>'  ></asp:TextBox>
                    <asp:RequiredFieldValidator ID="req1" runat="Server" Text="*" ControlToValidate="txtUserName"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Role Name" ItemStyle-Width="100px">
                <ItemTemplate>
                    <%# Eval("Name") %>
                </ItemTemplate>

                <EditItemTemplate>
                    <asp:TextBox ID="txtName" runat="Server" Columns="30"
                        Text='<%# Eval("Name") %>'></asp:TextBox>
                    <asp:RequiredFieldValidator ID="req2" runat="Server" Text="*" ControlToValidate="txtName"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>

            <asp:TemplateField HeaderText="Delete?">
                <ItemTemplate>
                    <span onclick="return confirm('Are you sure to Delete the record?')">
                        <asp:LinkButton ID="lnkB" runat="Server" Text="Delete" CommandName="Delete" CommandArgument="<%# Eval("UserName") %>" onclick="ENameLinkBtn_Click"></asp:LinkButton>
                    </span>
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>


        <SelectedRowStyle ForeColor="White" Font-Bold="True"
            BackColor="#738A9C"></SelectedRowStyle>
        <RowStyle ForeColor="#8C4510"
            BackColor="#FFF7E7"></RowStyle>
    </asp:GridView>
    </div>

    <asp:SqlDataSource
        ID="SqlDataSource1"
        runat="server"
        DataSourceMode="DataReader"
        ConnectionString="<%$ ConnectionStrings:DefaultConnection%>"
        SelectCommand="select AspNetUserRoles.UserId, AspNetUsers.UserName, AspNetRoles.Name from AspNetUserRoles  inner join AspNetUsers on AspNetUsers.Id = AspNetUserRoles.UserId inner join AspNetRoles on AspNetUserRoles.RoleId = AspNetRoles.Id"
        >
    </asp:SqlDataSource>


</asp:Content>
